// src/routes/launches/launches.controller.js
const {
    getAllLaunches,
    addNewLaunch,
    existsLaunchWithId,
    abortLaunchById,
} = require('../../models/launches.model');
function httpGetAllLaunches(req, res) {
    return res.status(200).json(getAllLaunches());
}
// 取消指定 ID 的发射任务
function httpAbortLaunch(req, res) {
    const launchId = Number(req.params.id);
    if (!existsLaunchWithId(launchId)) {
        return res.status(404).json({
            error: '发射任务不存在',
        });
    }
    const aborted = abortLaunchById(launchId);
    return res.status(200).json(aborted);
}
module.exports = {
    httpGetAllLaunches,
    httpAddNewLaunch,
    httpAbortLaunch,
};